//
//  StockInquiryCell.m
//  ProjectforHDX
//
//  Created by Jaesun on 16/8/3.
//  Copyright © 2016年 H.DX. All rights reserved.
//

#import "StockInquiryCell.h"

@implementation StockInquiryCell
- (instancetype) initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self s_setupCellView];
    }
    return self;
}

- (void)setPlateModel:(PlateModel *)plateModel {

    self.nameLab.text = plateModel.warehouse;
    self.wbsLab.text = plateModel.wbs;
    self.codeLab.text = plateModel.name;
    self.verLab.text = plateModel.code;
    self.numLab.text = plateModel.number;
    
    
    [self layoutSubviews];
    
}

- (void)s_setupCellView {
    
    self.nameLab = [[RZCustomLable alloc] init];
    self.nameLab.font = CustomFont(13);
    self.nameLab.numberOfLines = 0;
    self.nameLab.textColor = [UtilCheck hexStringToColor:@"6c6c6c" alpha:1];
    self.nameLab.textAlignment = NSTextAlignmentCenter;
    [self.contentView addSubview:self.nameLab];
    
    
    self.codeLab = [[RZCustomLable alloc] init];
    self.codeLab.font = CustomFont(13);
    self.codeLab.textColor = [UtilCheck hexStringToColor:@"6c6c6c" alpha:1];
    self.codeLab.textAlignment = NSTextAlignmentCenter;
    [self.contentView addSubview:self.codeLab];
    
    self.verLab = [[RZCustomLable alloc] init];
    self.verLab.font = CustomFont(13);
    self.verLab.textColor = [UtilCheck hexStringToColor:@"6c6c6c" alpha:1];
    self.verLab.textAlignment = NSTextAlignmentCenter;
    [self.contentView addSubview:self.verLab];
    
    self.numLab = [[RZCustomLable alloc] init];
    self.numLab.font = CustomFont(13);
    self.numLab.textColor = [UtilCheck hexStringToColor:@"6c6c6c" alpha:1];
    self.numLab.textAlignment = NSTextAlignmentCenter;
    [self.contentView addSubview:self.numLab];
    
    self.wbsLab = [[RZCustomLable alloc] init];
    self.wbsLab.font = CustomFont(13);
    self.wbsLab.textColor = [UtilCheck hexStringToColor:@"6c6c6c" alpha:1];
    self.wbsLab.textAlignment = NSTextAlignmentCenter;
    [self.contentView addSubview:self.wbsLab];
    
 
    self.cellHeight = self.nameLab.height;
}

- (void)layoutSubviews
{
    CGRect frame = [self.nameLab.text boundingRectWithSize:CGSizeMake(SCREEN_WIDTH / 5, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:16]} context:nil];
    
    [self.nameLab setFrame:frame];
    self.nameLab.center =CGPointMake(SCREEN_WIDTH / 10, self.height/2);

//    self.nameLab.top = 0;
    
    [self.wbsLab setFrame:CGRectMake(SCREEN_WIDTH / 5 - 5 , 0, SCREEN_WIDTH / 5, self.height)];
    
    [self.codeLab setFrame:CGRectMake(SCREEN_WIDTH / 5 * 2, 0, SCREEN_WIDTH / 5, self.height)];
    
    [self.verLab setFrame:CGRectMake(SCREEN_WIDTH / 5 * 3, 0, SCREEN_WIDTH / 5, self.height)];
    
    [self.numLab setFrame:CGRectMake(SCREEN_WIDTH / 5 * 4, 0, SCREEN_WIDTH / 5, self.height)];
    
    
    
    self.cellHeight = self.verLab.height;
    if (self.cellHeight < 40) {
        self.cellHeight = self.cellHeight + 20;
    }
    
    
}


@end
